// ValidationAspects
// Written by Mike Saunders
// Released under Microsoft Public License (Ms-PL)
using System;
using ValidationAspects.Factories;
using ValidationAspects.Sdk;

namespace ValidationAspects
{
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = true, Inherited = false)]
	public sealed class NotEqualAttribute : ValidatorAttribute
	{
		private readonly double _value;
		private readonly string _text;
		private readonly bool _ignoreCase;

		public NotEqualAttribute(double value)
		{
			_value = value;
		}

		public NotEqualAttribute(string value)
		{
			Enforce.IsNotNull(value, "value");
			_text = value;
		}


		public NotEqualAttribute(string value, bool ignoreCase)
		{
			Enforce.IsNotNull(value, "value");
			_text = value;
			_ignoreCase = ignoreCase;
		}

		#region Overrides of ValidatorAttribute
		public override IValidatorFactory Factory
		{
			get { return _text == null ? new NotEqual {Number = _value} : new NotEqual {Text = _text, IgnoreCase = _ignoreCase}; }
		}
		#endregion
	}
}